<!--河南星辰软件科技有限公司
@copyright Copyright (c) 2010~2022 All rights reserved.
-->
<template>
  <div class='app-container'>
    <el-row>
      <el-col :span='22' :xs='24'>
        <el-menu default-active='active' mode='horizontal' class='menu-unit'>
          <el-menu-item v-for='item in Container2' :index="'权限'===item.name?'active':'default'">
            <el-link @click="gotoMenu(item.url)" :type="'权限'===item.name?'primary':'default'">{{item.page_desc||item.name}}</el-link>
          </el-menu-item>
        </el-menu>
        <table cellpadding="4" cellspacing="0" border="0" width="100%">
          <tr>
            <td class="containerBack">
              <el-form ref="form" :model="t_user" :rules="rules" label-width="100px" id="mvcfm">
                <el-button @click="gotoPage('/crm/sale/contacts/PermissionSendMail?'+vueparams+'')" type='primary' size="mini">启用</el-button>
                <el-button @click="disable('')" type='primary' size="mini">禁用</el-button>
                <div class="form-unit">
                  <span class="mvc-title-left"> 联系人权限 </span>
                </div>
                <div>
                  <el-row>
                    <el-col :span="24">
                      <el-form-item label="账号" prop="">
                        {{t_user.username}}
                      </el-form-item>
                    </el-col>
                  </el-row>
                  <el-row>
                    <el-col :span="24">
                      <el-form-item label="名称" prop="">
                        {{t_user.person_name}}
                      </el-form-item>
                    </el-col>
                  </el-row>
                  <el-row>
                    <el-col :span="24">
                      <el-form-item label="账号状态" prop="">
                        {{getValueName("禁用=0,启用=1",t_user.enabled)}}
                      </el-form-item>
                    </el-col>
                  </el-row>
                  <el-row>
                    <el-col :span="24">
                      <el-form-item label="注册时间" prop="">
                        {{getDateTimeString(t_user,'entered')}}
                      </el-form-item>
                    </el-col>
                  </el-row>
                </div>
              </el-form>
            </td>
          </tr>
        </table>
      </el-col>
      <el-col :span='2' :xs='24'>
        <el-menu default-active='active' class='menu-unit'>
          <el-menu-item v-for='item in Container'>
            <el-link @click="gotoMenu(item.url)" :type="'联系人'===item.name?'primary':'default'">{{item.page_desc||item.name}}</el-link>
          </el-menu-item>
        </el-menu>
      </el-col>
    </el-row>
  </div>
</template>
<script>
  import request from '@/utils/request'
  export default {
    name: 'PotentialCustomerRights',
    components: {},
    props: ['popparams'],
    data() {
      return {
        vueparams: this.getVUEParams(""),
        t_user: {
          username: null,
          person_name: null,
          enabled: null,
          entered: null,
        },
        loading: false,
        Container: null,
        Container2: null,
        rules: {}
      }
    },
    created() {
      this.getData();
      this.loadContainerMenu({
        pid: "80299289AF2443B18EA545A4C0C37170",
        name: "客户管理右菜单",
        selected: "联系人"
      }, 'Container', this.vueparams);
      this.loadContainerMenu({
        pid: "14ED91704E794C43A973E8BEFF724C15",
        name: "客户联系人右菜单",
        selected: "权限"
      }, 'Container2', this.vueparams);
    },
    updated() {},
    mounted() {},
    methods: {
      getData() {
        request({
          method: 'get',
          url: '/xcapi/VUEAction/crm/sale/contacts/PotentialCustomerRights/potentialCustomerRights?' + this.vueparams,
        }).then(data => {
          for (var k in data) {
            if (Array.isArray(data[k])) {
              this[k] = data[k];
            } else {
              $.extend(this[k], data[k]);
            }
          }
        })
      },
      disable(_params) {
        request({
          method: 'post',
          url: '/xcapi/VUEAction/crm/sale/contacts/PotentialCustomerRights/disable?' + _params + this.vueparams,
          data: this.postData()
        }).then(data => {
          this.$router.replace("/redirect" + this.$route.fullPath);
          this.msgSuccess(data.msg);
        })
      },
    },
  }
</script>
